home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ifp1s155.zip / PAGE_16.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-21  |  7KB  |  226 lines

  1. unit page_16;
  2.  
  3. interface
  4.  
  5. uses crt, ifpglobl, ifpcomon, ifpextrn;
  6.  
  7. procedure page16;
  8.  
  9. implementation
  10.  
  11. procedure page16;
  12.   var
  13.     bootrec : array[0..secsiz - 1] of byte;
  14.     i : 1..26;
  15.     j : word;
  16.     l : longint;
  17.     xbool : boolean;
  18.     xbyte : byte;
  19.     xchar : char;
  20.     xword1 : word;
  21.     xword2 : word;
  22.     xword3 : word;
  23.     xword4 : word;
  24.     xword5 : word;
  25.     bpbsize: word;
  26.     ch2: char2;
  27.     direc: directions;
  28.  
  29.   begin
  30.   Window(1, 3, twidth div 2, tlength - 2);
  31.   caption1('Boot record of ');
  32.   drvname(currdrv);
  33.   Writeln;
  34.   xword1:=diskread(currdrv, 0, 1, bootrec);
  35.   if xword1 = $0000 then
  36.     begin
  37.     media(bootrec[$15], bootrec[$0D]);
  38.     caption3('Sectors/cluster');
  39.     Writeln(bootrec[$0D]);
  40.     caption3('Bytes/sector');
  41.     Writeln(cbw(bootrec[$0B], bootrec[$0C]));
  42.     caption3('Reserved sectors');
  43.     Writeln(cbw(bootrec[$0E], bootrec[$0F]));
  44.     caption3('FAT''s');
  45.     Writeln(bootrec[$10]);
  46.     caption3('Sectors/FAT');
  47.     Writeln(cbw(bootrec[$16], bootrec[$17]));
  48.     caption3('Root directory entries');
  49.     Writeln(cbw(bootrec[$11], bootrec[$12]));
  50.     Writeln;
  51.     caption3('Heads');
  52.     Writeln(cbw(bootrec[$1A], bootrec[$1B]));
  53.     caption3('Total sectors');
  54.     xword1:=bootrec[$13] + word(bootrec[$14] shl 8);
  55.     if xword1 = 0 then
  56.       begin
  57.       l:=bootrec[$20] + (bootrec[$21] * $100) +
  58.         (bootrec[$22] * $10000) + (bootrec[$23] * $1000000);
  59.       Writeln(l)
  60.       end
  61.     else
  62.       Writeln(cbw(bootrec[$13], bootrec[$14]));
  63.     caption3('Sectors/track');
  64.     Writeln(cbw(bootrec[$18], bootrec[$19]));
  65.     caption3('Hidden sectors');
  66.     if xword1 = 0 then
  67.       begin
  68.       l:=bootrec[$1C] + (bootrec[$1D] * $100) +
  69.         (bootrec[$1E] * $10000) + (bootrec[$1F] * $1000000);
  70.       Writeln(l)
  71.       end
  72.     else
  73.       Writeln(cbw(bootrec[$1C], bootrec[$1D]));
  74.     caption3('OEM name and version');
  75.     for i:=$03 to $0A do
  76.       Write(showchar(chr(bootrec[i])));
  77.     Writeln;
  78.     caption3('Extended boot record');
  79.     if (osmajor >= 4) and (bootrec[$26] = $29) then
  80.       begin
  81.       Writeln('yes');
  82.       caption3('Physical drive number');
  83.       Writeln(bootrec[$24]);
  84.       caption3('Volume label');
  85.       for j:=$2B to $35 do
  86.         Write(showchar(Chr(bootrec[j])));
  87.       Writeln;
  88.       caption3('Serial Number');
  89.       Writeln(hex(cbw(bootrec[$29], bootrec[$2A]), 4), '-',
  90.         hex(cbw(bootrec[$27], bootrec[$28]), 4));
  91.       caption3('FAT type');
  92.       for j:=$36 to $3D do
  93.         Write(showchar(Chr(bootrec[j])))
  94.       end
  95.     else
  96.       Writeln('no')
  97.     end
  98.   else
  99.     begin
  100.     Writeln('  Can''t read boot record');
  101.     Write('  ');
  102.     xbyte:=hi(xword1);
  103.     case xbyte of
  104.       $80 : Writeln('Attachment failed to respond');
  105.       $40 : Writeln('Seek operation failed');
  106.       $20 : Writeln('Controller failed');
  107.       $10 : Writeln('Data error (bad CRC)');
  108.       $08 : Writeln('DMA failure');
  109.       $04 : Writeln('Sector not found');
  110.       $03 : Writeln('Write-protect fault');
  111.       $02 : Writeln('Bad address mark');
  112.       $01 : Writeln('Bad command');
  113.       $00 : Writeln
  114.       else
  115.         unknown('error', xbyte, 2)
  116.     end;
  117.     Write('  ');
  118.     xbyte:=lo(xword1);
  119.     case xbyte of
  120.       $00 : Writeln('Write-protect error');
  121.       $01 : Writeln('Unknown unit');
  122.       $02 : Writeln('Drive not ready');
  123.       $03 : Writeln('Unknown command');
  124.       $04 : Writeln('Data error (bad CRC)');
  125.       $05 : Writeln('Bad request structure length');
  126.       $06 : Writeln('Seek error');
  127.       $07 : Writeln('Unknown media type');
  128.       $08 : Writeln('Sector not found');
  129.       $09 : Writeln('Printer out of paper');
  130.       $0A : Writeln('Write fault');
  131.       $0B : Writeln('Read fault');
  132.       $0C : Writeln('General failure')
  133.       else
  134.         unknown('error', xbyte, 2)
  135.     end
  136.     end;
  137.   Window(1 + twidth div 2, 3, twidth, tlength - 2);
  138.   i:=1;
  139.   xbool:=false;
  140.   xword1:=MemW[devseg : devofs + $0018];
  141.   xword2:=MemW[devseg : devofs + $0016];
  142.   if (osmajor >= 4) and (osmajor < 10) then
  143.     begin
  144.     xbyte:=1;
  145.     bpbsize:=$58
  146.     end
  147.   else
  148.     begin
  149.     xbyte:=0;
  150.     bpbsize:=$51
  151.     end;
  152.   repeat
  153.     caption1('DOS disk parameter block for ');
  154.     xword2:=MemW[devseg : devofs + $0016] + ((i - 1) * bpbsize);
  155.     drvname(i - 1);
  156.     Writeln;
  157.     xword3:=MemW[xword1 : xword2 + $0047];
  158.     xword4:=MemW[xword1 : xword2 + $0045];
  159.     media(Mem[xword3 : xword4 + $0016 + xbyte],
  160.           Mem[xword3 : xword4 + $0004] + 1);
  161.     caption3('Sectors/cluster');
  162.     Writeln(Mem[xword3 : xword4 + $0004] + 1);
  163.     caption3('Bytes/sector');
  164.     Writeln(MemW[xword3 : xword4 + $0002]);
  165.     caption3('Reserved sectors');
  166.     Writeln(MemW[xword3 : xword4 + $0006]);
  167.     caption3('FAT''s');
  168.     Writeln(Mem[xword3 : xword4 + $0008]);
  169.     caption3('Sectors/FAT');
  170.     if (osmajor >= 4) and (osmajor <10) then
  171.       Writeln(Mem[xword3:xword4 + $000F] +
  172.           (Mem[xword3:xword4 + $0010] * 256))
  173.     else
  174.       Writeln(Mem[xword3 : xword4 + $000F]);
  175.     caption3('Root directory entries');
  176.     Writeln(MemW[xword3 : xword4 + $0009]);
  177.     Writeln;
  178.     caption3('DPB valid');
  179.     yesorno(Mem[xword3 : xword4 + $0017 + xbyte] < $FF);
  180.     caption3('Current directory');
  181.     j:=xword2;
  182.     xchar:=chr(Mem[xword1 : j]);
  183.     while xchar > #0 do begin
  184.       Write(xchar);
  185.       inc(j);
  186.       xchar:=chr(Mem[xword1 : j])
  187.     end;
  188.     Writeln;
  189.     caption3('Device header');
  190.     segofs(MemW[xword3 : xword4 + $0014 + xbyte],
  191.       MemW[xword3 : xword4 + $0012 + xbyte]);
  192.     Writeln;
  193.     caption3('Unit within driver');
  194.     Writeln(Mem[xword3 : xword4 + $0001]);
  195.     caption3('Clusters');
  196.     Writeln(MemW[xword3 : xword4 + $000D] - 1);
  197.     caption3('Cluster to sector shift');
  198.     Writeln(Mem[xword3 : xword4 + $0005]);
  199.     caption3('Root directory sector');
  200.     Writeln(MemW[xword3 : xword4 + $0010 + xbyte]);
  201.     caption3('First data sector');
  202.     Writeln(MemW[xword3 : xword4 + $000B]);
  203.     caption3('Next DPB');
  204.     xword5:=MemW[xword3 : xword4 + $0018 + xbyte];
  205.     segofs(MemW[xword3 : xword4 + $001A + xbyte], xword5);
  206.     Writeln;
  207.     if i = 1 then
  208.       direc:=down
  209.     else
  210.       if (i = lastdrv) or (xword5 = $FFFF) then
  211.         direc:=up
  212.       else
  213.         direc:=updown;
  214.     Write('  ');
  215.     pause4(direc, ch2);
  216.     if endit then
  217.       Exit;
  218.     if (ch2 = #0#72) and (i > 1) then
  219.       Dec(i)
  220.     else
  221.       if (ch2 = #0#80) and (i < lastdrv) and (xword5 < $FFFF) then
  222.         Inc(i);
  223.     ClrScr;
  224.   until xbool
  225.   end;
  226. end.